package com.example.service;

import com.example.mapper.NewsMapper;
import com.example.pojo.News;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class NewsService {

    @Autowired
    private NewsMapper newsMapper;

    public News selectById(Integer id) {
       News news = newsMapper.selectById(id);
        return news;
    }

    public void addNews(News news) {
        newsMapper.addNews(news);
    }

//    查询全部新闻
    public List<News> selectAll() {
        List<News> news1 = (List<News>) newsMapper.selectAll();
        return news1;
    }
}
